import { createApp } from "vue";
import App from "./App.vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
// 引入中文包
import zhCn from "element-plus/dist/locale/zh-cn";

import pinia from "./store/pinia";
// 先导入路由
import router from "./router/index.js";
// 后导入权限设置
import { setupRouterGuards } from "./router/permission.js";

const app = createApp(App);

app.use(pinia);
app.use(router);
app.use(ElementPlus, { size: "small", zIndex: 3000, locale: zhCn, });

// 注册 Element Plus 的图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 在所有初始化完成后设置路由守卫
setupRouterGuards();

// Mount the app to the div#app element.
app.mount("#app");
